package com.twu.biblioteca;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by root on 4/24/14.
 */
public class Customer {
    private String name;
    private String libraryNumber;
    private String password;
    private String phoneNo;
    private String emailID;
    private List<Book> checkedOutBooks = new ArrayList<Book>();
    private List<Movie> checkedOutMovies = new ArrayList<Movie>();

    public Customer(String name,String phoneNo,String emailID,String libraryNumber,String password){

        this.name = name;
        this.phoneNo = phoneNo;
        this.emailID = emailID;
        this.libraryNumber = libraryNumber;
        this.password = password;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setPhoneNo(String phoneNo){this.phoneNo = phoneNo;}

    public void setEmailID(String emailID){this.emailID = emailID;}

    public void setCheckedOutBook(Book checkedOutBook) {
        this.checkedOutBooks.add(checkedOutBook);
    }

    public void setLibraryNumber(String libraryNumber) {
        this.libraryNumber = libraryNumber;
    }

    public String getLibraryNumber() {
        return libraryNumber;
    }

    public String getEmailID() {
        return emailID;
    }

    public String getPhoneNo() {
        return phoneNo;
    }

    public List<Book> getCheckedOutBooks() {
        return checkedOutBooks;
    }

    public String getName() {
        return name;
    }

    public void removeCheckedOutBook(Book book){

        int index = this.checkedOutBooks.indexOf(book);
        this.checkedOutBooks.remove(index);
    }

    public List<Movie> getCheckedOutMovie() {
        return checkedOutMovies;
    }

    public void setCheckedOutMovie(Movie checkedOutMovie) {
        this.checkedOutMovies.add(checkedOutMovie);
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getPassword() {
        return password;
    }

    public void showProfile(){

        System.out.println("Name:"+getName());
        System.out.println("LibraryNumber:"+ getLibraryNumber());
        System.out.println("Phone Number:"+ getPhoneNo());
        System.out.println("EmailID:"+ getEmailID());
        new BibliotecaApp().showMenu("");

    }

    public boolean checkIfCheckedOut(String option){


        if(checkedOutMovies.isEmpty()){ return false;}
        else {
            for (Movie movie:checkedOutMovies){
                if(movie.getId().equals(option)){
                    return true;
                }
            }
        }
        return false;

    }
}
